<?php
include "../includes/curl_function.php";
$loc    = gpc_getStringGet('loc');
$codes  = array();
if($actPost=="searchcode")
{
    $post='__RequestVerificationToken='. urlencode(gpc_getStringPost('__RequestVerificationToken'));
    $post.='&locId='. gpc_getStringPost('locId');

    $data   = curl2('http://aspnetresources.com/tools/WeatherIdResolver',$post,1,0,'http://aspnetresources.com/tools/WeatherIdResolver');
    $data   = substr($data,strpos($data,"<tbody>"));
    $data   = substr($data,0,strpos($data,"</tbody"));
    $arr    = explode("<tr>",$data);

    for($i=1;$i<count($arr);$i++)
    {
        $tr=explode("<td>",$arr[$i]);
        if(count($tr)>=2)
        {
            $code   = str_replace("</td>","",$tr[1]);
            $name   = preg_replace("((.*)(\<\/td\>)(.*))","$1",$tr[2]);
            $code   = str_replace("\r\n","",$code);  
            $code   = str_replace("\n",'',$code); 
            $code   = trim($code); 
            $codes []= array($code,$name);
        }
    }
}

$data   = curl2('http://aspnetresources.com/tools/WeatherIdResolver',null,0);
$data   = str_replace(array("\n","\r"),array("",""),$data);
$key    = preg_replace("/(.*)(RequestVerificationToken)([^\>]*)(value=\")([^\>]*)(\")(.*)/i","$5",$data);
?>